package com.deyang.share.controller;

import com.deyang.share.model.User;
import com.deyang.share.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-10-17
 * Time: 上午9:36
 * To change this template use File | Settings | File Templates.
 */

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    public UserService getUserService() {
        return userService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    public String getUser(@PathVariable Long id,Model model){
        System.out.println("xxxxxxxx");
        return "index";
    }


    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public String addUser(@ModelAttribute User user){
        userService.addUser(user);
        return "redirect:/index";
    }


}
